home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / c / supralib / developer / source.org / _move.c < prev    next >
C/C++ Source or Header  |  1999-06-14  |  2KB  |  57 lines

  1. /*******************************************************************
  2. *
  3. *    ---------------
  4. *   * Supra library *
  5. *    ---------------
  6. *
  7. *   -- Move file demo --
  8. *   Demonstration of FCopy() function.
  9. *
  10. *   This is a simple program that moves a source file to a
  11. *   destination file.
  12. *   Usage is: Move sfile dfile
  13. *   sfile = source file to be moved
  14. *   dfile = destination file
  15. *
  16. *   Example: move c:list ram:ls
  17. *   (will copy c:list to ram:ls, and delete c:list)
  18. *
  19. *
  20. *   ©1995 by Jure Vrhovnik -- all rights reserved
  21. *   jurev@gea.fer.uni-lj.si
  22. *
  23. *******************************************************************/
  24.  
  25. #include <clib/dos_protos.h>
  26. #include <dos/dos.h>
  27. #include <libraries/supra.h>
  28. #include <stdio.h>
  29.  
  30. main(int argc, char *argv[])
  31. {
  32. UBYTE err;
  33.  
  34.     if (argc == 0) {    /* Started from WB */
  35.         printf("Please start this from CLI\n");
  36.     } else if (argc != 3) {  /* Move needs exactly two arguments */
  37.         printf("Usage: %s source dest\n",argv[0]);
  38.     } else {
  39.         if (err = FCopy(argv[1], argv[2], 0)) { /* Error occured */
  40.             switch(err) {
  41.                 case FC_ERR_EXIST:
  42.                     printf("%s does not exist\n", argv[1]);
  43.                     break;
  44.                 case FC_ERR_DEST:
  45.                     printf("Error writing to %s\n", argv[2]);
  46.                     break;
  47.                 default:
  48.                     printf("Error: cannot move the file\n");
  49.             }
  50.         } else {
  51.             if (!(DeleteFile(argv[1]))) printf("Cannot delete source file\n");
  52.             printf("File moved\n");
  53.         }
  54.     }
  55. }
  56.  
  57.